package com.tangdi;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

import com.tangdi.Dao.impl.SystemParameterImpl;

public class Utils {
	public static void main(String[] args) {
		String ss = "201905";
		System.out.println(ss.substring(2, 4) + "-" +ss.substring(4, 6));
	}
	
	public static void setFieldReflect(Object object,Class<?> objectClass, String fieldName,String fieldValue){
		try {
			Field f = objectClass.getDeclaredField(fieldName);
			f.setAccessible(true);
			f.set(object, fieldValue);
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
	
	public static Object getFieldReflect(Object object,Class<?> objectClass, String fieldName){
		try {
			Field f = objectClass.getDeclaredField(fieldName);
			f.setAccessible(true);
			return f.get(object);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
	}
	
	public static String getXM_BM(String gzlb){
		Map<String,String>  mapping = new HashMap<String,String>();
		mapping.put("DKXJ", "DK_XJ");
		mapping.put("YFGZ", "YF_GZ");
		mapping.put("SFGZ", "SF_TXN_AMT");
		
		String gzlb_str = gzlb;
		if(gzlb.length() > 4){
			gzlb_str = "B0" + String.format("%0" + 2 + "d", Integer.parseInt(gzlb.substring(4, gzlb.length())));
		}else{
			gzlb_str = mapping.get(gzlb_str);
		}
		return gzlb_str;
	}
	
	public static String getFilePath(String pathName){
		SystemParameterImpl sp = new SystemParameterImpl();
		String path = "";
		path = sp.getPath(pathName);
		return path;
	}
}
